package de.servicezombie.tcmdb.rest.vo;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import de.servicezombie.pub.r1.XmlNamespaces;

/**
 * <p>
 * A program that shold be tested, like Webshop, ERM System, ...
 * </p>
 * <b>Example:</b>
 * 
 * <pre>
 * application {
 *   name: "Webshop",
 *   project: "n.a."
 * }
 * </pre>
 * 
 * @author ChKa
 * @version n.a.
 */
@XmlRootElement(name = "application", namespace = XmlNamespaces.SERVICEZOMBIE_COMMON)
@XmlAccessorType(XmlAccessType.FIELD)
public class WsApplication {

	@XmlElement(name = "name", namespace = XmlNamespaces.SERVICEZOMBIE_COMMON)
	private String name;

	@XmlElement(name = "project", namespace = XmlNamespaces.SERVICEZOMBIE_COMMON)
	private String project;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getProject() {
		return project;
	}

	public void setProject(String project) {
		this.project = project;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(name).append(project).toHashCode();
	}

	@Override
	public boolean equals(Object obj) {
		
		if(obj != null && obj.getClass() == WsApplication.class) {
			WsApplication rhs = (WsApplication) obj;
			return new EqualsBuilder()
				.append(this.name, rhs.name)
				.append(this.project, rhs.project)
				.isEquals();
		}
		else {
			return false;
		}
		
	}
	
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
	}

}
